package com.javastudy.autowiredStudy.getrongqi;

import com.javastudy.autowiredStudy.strategy.IntegerToStringOfListConverter;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

/**
 * 获取ioc容器的方式之二：
 */
@Service
public class GetIOCByApplicationContextAware implements ApplicationContextAware {
    private ApplicationContext applicationContext;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public void getIOC() {
        IntegerToStringOfListConverter integerToStringOfListConverter = (IntegerToStringOfListConverter) applicationContext.getBean("integerToStringOfListConverter");
        System.out.println("integerToStringOfListConverter = " + integerToStringOfListConverter);

    }
}
